package com.nc.delivery_project.shared.locator;

import com.google.web.bindery.requestfactory.shared.Locator;
import com.nc.delivery_project.server.domain.Currency;
import com.nc.delivery_project.server.service.CurrencyService;
import com.nc.delivery_project.shared.servicelocator.CurrencyServiceLocator;

/**
 * Created by miroshnik on 1/28/2015.
 */
public class CurrencyLocator extends Locator<Currency, Integer> {
    @Override
    public Currency create(Class<? extends Currency> clazz) {
        return new Currency();
    }

    @Override
    public Currency find(Class<? extends Currency> clazz, Integer id) {
        return ((CurrencyService) new CurrencyServiceLocator().getInstance(null)).read(id);
    }

    @Override
    public Class<Currency> getDomainType() {
        return Currency.class;
    }

    @Override
    public Integer getId(Currency domainObject) {
        return domainObject.getId();
    }

    @Override
    public Class<Integer> getIdType() {
        return Integer.class;
    }

    @Override
    public Object getVersion(Currency domainObject) {
        return domainObject.getId();
    }
}
